package com.ruoyi.system.controller;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.system.domain.SysCompanyReportTemplate;
import com.ruoyi.system.service.ISysCompanyReportTemplateService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 诊断报告领域模版库Controller
 * 
 * @author ruoyi
 * @date 2023-08-19
 */
@Api(tags = "企业诊断报告领域模版库")
@RestController
@RequestMapping("/report/template")
public class SysCompanyReportTemplateController extends BaseController
{
    @Autowired
    private ISysCompanyReportTemplateService sysCompanyReportTemplateService;

    /**
     * 查询诊断报告领域模版库列表
     */
    @ApiOperation(value = "查询诊断报告领域模版库列表")
    //   @PreAuthorize("@ss.hasPermi('system:info:list')")
    @GetMapping("/list")
    public AjaxResult list(SysCompanyReportTemplate sysCompanyReportTemplate)
    {

        List<SysCompanyReportTemplate> list = sysCompanyReportTemplateService.selectSysCompanyReportTemplateList(sysCompanyReportTemplate);
        return AjaxResult.success(list);
    }

    /**
     * 查询诊断报告领域模版库列表
     */
   // @PreAuthorize("@ss.hasPermi('system:template:list')")
    @GetMapping("/page")
    @ApiOperation(value = "查询诊断报告领域模版库列表(分页)")
    public TableDataInfo listPage(SysCompanyReportTemplate sysCompanyReportTemplate)
    {
        startPage();
        List<SysCompanyReportTemplate> list = sysCompanyReportTemplateService.selectSysCompanyReportTemplateList(sysCompanyReportTemplate);
        return getDataTable(list);
    }

    /**
     * 导出诊断报告领域模版库列表
     */
   // @PreAuthorize("@ss.hasPermi('system:template:export')")
    @Log(title = "诊断报告领域模版库", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SysCompanyReportTemplate sysCompanyReportTemplate)
    {
        List<SysCompanyReportTemplate> list = sysCompanyReportTemplateService.selectSysCompanyReportTemplateList(sysCompanyReportTemplate);
        ExcelUtil<SysCompanyReportTemplate> util = new ExcelUtil<SysCompanyReportTemplate>(SysCompanyReportTemplate.class);
        util.exportExcel(response, list, "诊断报告领域模版库数据");
    }

    /**
     * 获取诊断报告领域模版库详细信息
     */
  //  @PreAuthorize("@ss.hasPermi('system:template:query')")
    @GetMapping(value = "/{templateId}")
    @ApiOperation(value = "获取诊断报告领域模版库详细信息")
    public AjaxResult getInfo(@PathVariable("templateId") Long templateId)
    {
        return AjaxResult.success(sysCompanyReportTemplateService.selectSysCompanyReportTemplateByTemplateId(templateId));
    }

    /**
     * 新增诊断报告领域模版库
     */
   // @PreAuthorize("@ss.hasPermi('system:template:add')")
    @Log(title = "诊断报告领域模版库", businessType = BusinessType.INSERT)
    @PostMapping
    @ApiOperation(value = "新增诊断报告领域模版库")
    public AjaxResult add(@RequestBody SysCompanyReportTemplate sysCompanyReportTemplate)
    {
        return toAjax(sysCompanyReportTemplateService.insertSysCompanyReportTemplate(sysCompanyReportTemplate));
    }

    /**
     * 修改诊断报告领域模版库
     */
  //  @PreAuthorize("@ss.hasPermi('system:template:edit')")
    @Log(title = "诊断报告领域模版库", businessType = BusinessType.UPDATE)
    @PutMapping
    @ApiOperation(value = "修改诊断报告领域模版库")
    public AjaxResult edit(@RequestBody SysCompanyReportTemplate sysCompanyReportTemplate)
    {
        return toAjax(sysCompanyReportTemplateService.updateSysCompanyReportTemplate(sysCompanyReportTemplate));
    }

    /**
     * 删除诊断报告领域模版库
     */
  //  @PreAuthorize("@ss.hasPermi('system:template:remove')")
    @Log(title = "诊断报告领域模版库", businessType = BusinessType.DELETE)
	@DeleteMapping("/{templateIds}")
    @ApiOperation(value = "删除诊断报告领域模版库")
    public AjaxResult remove(@PathVariable Long[] templateIds)
    {
        return toAjax(sysCompanyReportTemplateService.deleteSysCompanyReportTemplateByTemplateIds(templateIds));
    }
}
